#pragma once

#define LIMIT_EPSILON 1E-12f

typedef int     (*MainFunc)(void);
typedef double  (*itrFunctor)( const double );
typedef double  (*PolyCalFunctor)( const double, const int*, const unsigned int );

// return -1 for fail 
char CheckedInputChar( const char* p_validityChars, const unsigned int p_cnt );

// include max and min
// return p_min-1 for fail
int CheckedInputInt( const int p_min, const int p_max );

// return -epsilon for fail
float CheckedInputFloat( const float p_min, const float p_max );

bool isConverged( const double x0, const double x1);

void logStep( const unsigned int i, const double x0, const double x1 );

void FinalLog( const unsigned int p_i, const double p_x0, const double p_x1 );

bool ItrProcess( const itrFunctor p_itrFunctor,
                 const double p_initValue,
                 const double p_epsilong = LIMIT_EPSILON,
                 const bool p_bLog = true );

//cal the C(r,n)
//not safe, not take considerations on the bound limit
unsigned int ChoiceC( const unsigned int r, const unsigned int n );

int* BinomalCoff( const unsigned int n );

